<?php 
$GLOBALS['Md'] = "Contabilidade";
$GLOBALS['Pd'] = "R";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."/Modules/Contabilidade/modconf.mex");
MYTCONN();
	// Total Vars
		$TCAR = 0;
		$TAVGRate = 0;
		$TSUMTax = 0;
		$TSUMSent = 0;
		$TSUMReceiv = 0;
	  $CVMOVS = $GLOBALS['MYT']->db_array("SELECT hd_caixa.REF, cvt_Name, sysTime, main_users.name AS sysUser, OriNombre, Amount, cxh_Time
				FROM hd_caixa
				INNER JOIN systemoffice.main_users ON main_users.ref = sysUser
				INNER JOIN hd_cashiertypes ON cvt_ID = hd_caixa.TYPE
				INNER JOIN origenes ON OriNumero = sysOffice
	  	WHERE DATE({$_POST['QurType']}) BETWEEN '{$_POST['TimeStart']}' AND '{$_POST['TimeEnd']}'"); ?>

<script charset="utf-8" type="text/javascript">
disableSelection(document.getElementById("Cashier_Balc")); //Disable text selection on element with id="mydiv"

Ext.onReady(function(){

    Ext.QuickTips.init();

    var myData = [
	<?php   

	  for ($t = 1; $t <= $CVMOVS[0]; $t++) {
	echo '['.$t.','.$CVMOVS[$t]['REF'].',\''.$CVMOVS[$t]['cvt_Name'].'\',\''.$CVMOVS[$t]['sysUser'].'\',\''.$CVMOVS[$t]['sysTime'].'\',\''.$CVMOVS[$t]['OriNombre'].'\',\''.$CVMOVS[$t]['Amount'].'\',\''.$CVMOVS[$t]['cxh_Time'].'\']';
		if ($t<$CVMOVS[0]) {
			echo ',';
		}
    } ?>
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'id'},
			   {name: 'ID0', type: 'int'},
               {name: 'COL4', type: 'string'},
               {name: 'COL1', type: 'string'},
               {name: 'COL2', type: 'string'},
			   {name: 'COL3', type: 'string'},
			   {name: 'COL5', type: 'string'},
			   {name: 'COL6', type: 'string'}
          ])
    });
    ds.loadData(myData);
    var colModel = new Ext.grid.ColumnModel([
        {header: "Caixa", width: 60, sortable: true, locked:true, dataIndex: 'ID0'},
        {header: "Funcionario", width: 180, sortable: true, locked:true, dataIndex: 'COL1'},
        {header: "Data do Fecho", width: 120, sortable: true, dataIndex: 'COL2'},
        {header: "Data do Caixa", width: 120, sortable: true, dataIndex: 'COL6'},
        {header: "Loja", width: 150, sortable: true, locked:true, dataIndex: 'COL3'},
        {header: "Tipo", width: 150, sortable: true, locked:true, dataIndex: 'COL4'},
        {header: "Valor", width: 100, sortable: true, locked:true, align: 'right', dataIndex: 'COL5'}
    ]);
	
function ShowProp(id) { 
	var properties = new Ext.Window({
		title:'Propriedades',
		autoLoad: 'Modules/CJ38IJ56/prop_csh.mex?RSID='+id,
		modal:true,
		width:720,
		height:500,
		resizable:false
	});
properties.show();
}

   var selmode = new Ext.grid.RowSelectionModel({});
   var Console = new Ext.grid.GridPanel({
        layout: 'fit',
	    ds: ds,
		cm: colModel,
	    sm: selmode,
		listeners: {
	 			rowdblclick: function(ds, row) { 
				var record = ds.getStore().getAt(row);
  				var value = record.get('ID0');	
					ShowProp(value);
				}
		},
	    height: 400,
	    border: true,
	    renderTo: 'Cashier_Balc'
    });
});
</script>